package com.approval.approvalapp.center.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.approval.approval.QjkgBean;
import com.approval.approvalapp.R;
import com.approval.approvalapp.center.bean.QjkgBena;
import com.nostra13.universalimageloader.utils.L;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class QjkgAdapter extends RecyclerView.Adapter<QjkgAdapter.ViewHolder> {

    List<QjkgBean.AbsenteeismTodayBean> absenteeism_today;

    public void setAbsenteeism_today(List<QjkgBean.AbsenteeismTodayBean> absenteeism_today) {
        this.absenteeism_today = absenteeism_today;
        notifyDataSetChanged();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.qjkg_item,parent,false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        QjkgBean.AbsenteeismTodayBean  bean = absenteeism_today.get(position);
        holder.tvName.setText(bean.getXNAME());
        holder.tvProvince.setText(bean.getORGNAME());
        holder.tvState.setText("状态：旷工");
        holder.tvState.setBackgroundResource(R.drawable.red_radius_25_11);
        holder.tvState.setTextColor(Color.parseColor("#DE463A"));
    }

    @Override
    public int getItemCount() {
        if (absenteeism_today == null){
            return 0;
        }else {
            return absenteeism_today.size();
        }

    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.tv_name)
        TextView tvName;
        @Bind(R.id.tv_province)
        TextView tvProvince;
        @Bind(R.id.tv_state)
        TextView tvState;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void setData(QjkgBean.AbsenteeismTodayBean bean) {

            tvName.setText(bean.getXNAME());
            tvProvince.setText(bean.getORGNAME());
            int stateT = bean.getStateT();
            tvState.setText("状态：旷工");
            tvState.setBackgroundResource(R.drawable.blueshape4_11);
            tvState.setTextColor(Color.parseColor("#1076FF"));

        }
    }
}
